package Practice;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入车票价");
        double price = scanner.nextDouble();
        System.out.println("请输入月份");
        int month = scanner.nextInt();
        System.out.println("请输入舱位:1.头等舱 2.商务舱 3.经济舱");
        int type = scanner.nextInt();
        double finalPrice = finalPrice(price, month, type);
        if (finalPrice != -1) {
            System.out.println("折后票价是" + finalPrice);
        }

    }

    public static double finalPrice(double price, int month, int type) {
        double finalPrice = 0.0;
        if (month >= 1 && month <= 12) {
            if (type >= 1 && type <= 3) {


                if (month >= 2 && month <= 7) {
                    switch (type) {
                        case 1:
                            finalPrice = price * 0.8;
                            break;
                        case 2:
                            finalPrice = price * 0.85;
                            break;
                        case 3:
                            finalPrice = price * 0.9;
                            break;
                    }
                } else {
                    switch (type) {
                        case 1:
                            finalPrice = price * 0.8;
                            break;
                        case 2:
                            finalPrice = price * 0.85;
                            break;
                        case 3:
                            finalPrice = price * 0.9;
                            break;

                    }
                }
            } else {
                System.out.println("输入舱位错误");
                return -1;
            }
        } else {
            System.out.println("输入月份错误");
            return -1;
        }
        return finalPrice;
    }


}
